/*******************************************************************************
* company    : 六瓜编程 2010-2020
* description:    [ lg_timer ]
* date: 2020-12-14 01:04:53
* author : XiaoShengYang
*******************************************************************************/

#ifndef __LG_TIMER_H
#define __LG_TIMER_H
#include <lg_types.h>

typedef lg_void (*trace_car_callback)(lg_void *motor_data);

struct lg_timer_config {
    enum mode {
        TIMER_LOOP_MODE = 0,
        TIMER_SINGLE_MODE,
    };

    union para {
        /* 连续模式 */
        struct loop {
            /* 初始相位 */
            lg_s32 init_pahse;
            /* 时间间隔 */
            lg_s32 time_interval;
            /* 回调函数 */
            trace_car_callback callback;
        };

        /* 单次模式 */
        struct single {
            /* 初始相位 */
            lg_s32 init_pahse;
            /* 定时时间 */
            lg_s32 time_set;
            /* 回调函数 */
            trace_car_callback callback;
        };
    };
};

/* 暂时只支持一个软件定时器 */
lg_void lg_timer_init(struct lg_timer_config *timer_config);
lg_void lg_timer_deinit(struct lg_timer_config *timer_config);
lg_void lg_timer_start(lg_u32);
lg_void lg_timer_set_callback(trace_car_callback car_callback, lg_u16 time_ms);

#endif